package cn.initcap.concurrency.concurrency.unsafe;

import cn.initcap.concurrency.annoations.NotThreadSafe;
import cn.initcap.concurrency.concurrency.ThreadPoolCreatHelper;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import lombok.extern.slf4j.Slf4j;

/**
 * @author initcap
 * @date Created in 2018/6/16 PM1:33.
 */
@Slf4j
@NotThreadSafe
public class DateFormatExample1 {

    /**
     * 总请求数
     */
    private static final int CLIENT_TOTAL = 5000;
    /**
     * 同时并发执行的线程数
     */
    private static final int THREAD_TOTAL = 200;
    /**
     * 非线程安全的。
     */
    private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");

    public static void update() {
        try {
            simpleDateFormat.parse("2018-02-08");
        } catch (ParseException e) {
            log.info("Exception:{}", e);
        }
    }

    public static void main(String[] args) throws Exception {
        ThreadPoolCreatHelper.threadPoolRun(CLIENT_TOTAL, THREAD_TOTAL,
                DateFormatExample1.class, "update",
                "DateFormatExample1");
    }

}
